package com.bwie.House.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.house.entity.MapEntity;
import com.bwie.House.service.MapService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author wangmo
 * @email wangmo@gmail.com
 * @date 2021-10-13 19:50:25
 */
@RestController
@RequestMapping("house/map")
public class MapController {
    @Autowired
    private MapService mapService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = mapService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{mapid}")
    public R info(@PathVariable("mapid") Integer mapid){
		MapEntity map = mapService.getById(mapid);

        return R.ok().put("map", map);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MapEntity map){
		mapService.save(map);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MapEntity map){
		mapService.updateById(map);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] mapids){
		mapService.removeByIds(Arrays.asList(mapids));

        return R.ok();
    }

}
